package data;

import java.util.Date;

import com.EntityName;
import com.google.appengine.api.datastore.Entity;

public class Charge extends AbstractData{
	private long id = -1;
	private long hotelId;
	private Date chargeDate;
	private String description;
	private double discount;
	private double chargeAmount;
	private double tax;
	private boolean isLock;
	private String subFolio;
	private boolean isRoomCharge;
	private long Qty;
	private boolean isRefund;
	private long FolioId;
	private boolean isTemp;
	private long reasondetailId;
	private String emailMassage;
	private String chargeType;
	public Charge(){
		
	}
	public Charge(long id) {
		this.id = id;
	}

	public long getQty() {
		return Qty;
	}

	public void setQty(long Qty) {
		this.Qty = Qty;
	}
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}
	public long getHotelId() {
		return hotelId;
	}

	public void setHotelId(long hotelId) {
		this.hotelId = hotelId;
	}

	public Date getChargeDate() {
		return chargeDate;
	}

	public void setChargeDate(Date chargeDate) {
		this.chargeDate = chargeDate;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public double getDiscount() {
		return discount;
	}

	public void setDiscount(double discount) {
		this.discount = discount;
	}

	public double getChargeAmount() {
		return chargeAmount;
	}

	public void setChargeAmount(double chargeAmount) {
		this.chargeAmount = chargeAmount;
	}

	public double getTax() {
		return tax;
	}
	public void setTax(double tax) {
		this.tax = tax;
	}
	public boolean isLock() {
		return isLock;
	}
	public void setLock(boolean isLock) {
		this.isLock = isLock;
	}
	public String getSubFolio() {
		return subFolio;
	}
	public void setSubFolio(String subFolio) {
		this.subFolio = subFolio;
	}

	public boolean isRoomCharge() {
		return isRoomCharge;
	}
	
	public void setRoomCharge(boolean isRoomCharge) {
		this.isRoomCharge = isRoomCharge;
	}
	public boolean isRefund() {
		return isRefund;
		}
		public void setRefund(boolean isRefund) {
		this.isRefund = isRefund;
		}
		
	public long getFolioId() {
			return FolioId;
		}
		public void setFolioId(long folioId) {
			FolioId = folioId;
		}
		
	public boolean isTemp() {
			return isTemp;
		}
		public void setTemp(boolean isTemp) {
			this.isTemp = isTemp;
		}
	public long getReasondetailId() {
		return reasondetailId;
	}
	public void setReasondetailId(long reasondetailId) {
		this.reasondetailId = reasondetailId;
	}		
	public String getEmailMassage() {
			return emailMassage;
		}
	public void setEmailMassage(String emailMassage) {
			this.emailMassage = emailMassage;
		}
	public String getChargeType() {
		return chargeType;
	}
	public void setChargeType(String chargeType) {
		this.chargeType = chargeType;
	}
	@Override
	public Entity getEntity() {
		Entity item;
		if(this.key == null)
			item = new Entity(EntityName.Charge);
		else
			item = new Entity(this.key);

		item.setProperty("HotelId", this.hotelId);
		item.setProperty("Qty", this.Qty);
		item.setProperty("chargeDate", this.chargeDate);
		item.setProperty("discount", this.discount);
		item.setProperty("chargeAmount", this.chargeAmount);
		item.setProperty("description", this.description);
		item.setProperty("isLock", this.isLock);
		item.setProperty("subFolio", this.subFolio);
		item.setProperty("tax", this.tax);
		item.setProperty("isRoomCharge", this.isRoomCharge);
		item.setProperty("isRefund", this.isRefund);
		item.setProperty("FolioId", this.FolioId);
		item.setProperty("isTemp", this.isTemp);
		item.setProperty("reasondetailId",this.reasondetailId);
		item.setProperty("emailMassage", this.emailMassage);
		item.setProperty("chargeType", this.chargeType);
		return item;
	}

	@Override
	public void setEntity(Entity entity) {
		this.id = entity.getKey().getId();
		this.hotelId = (Long) entity.getProperty("HotelId");
		this.Qty = (Long) entity.getProperty("Qty");
		this.chargeDate = (Date) entity.getProperty("chargeDate");
		this.discount = (Double) entity.getProperty("discount");
		this.chargeAmount = (Double) entity.getProperty("chargeAmount");
		this.description = (String) entity.getProperty("description");
		this.tax = (Double) entity.getProperty("tax");
		this.isLock = (Boolean) entity.getProperty("isLock");
		this.subFolio = (String) entity.getProperty("subFolio");
		this.isRoomCharge = (Boolean) entity.getProperty("isRoomCharge");
		this.isRefund = (Boolean) entity.getProperty("isRefund");
		this.FolioId = (Long) entity.getProperty("FolioId");
		this.isTemp = (Boolean) entity.getProperty("isTemp");
		//TODO: tee edit 
		if(entity.getProperty("reasondetailId") == null){
			this.reasondetailId = 0;
		}else{
			this.reasondetailId =(Long) entity.getProperty("reasondetailId");
		}
		
		this.emailMassage =(String) entity.getProperty("emailMassage");
		this.chargeType =(String) entity.getProperty("chargeType");
		this.key = entity.getKey();
		
	}
	
	public void LoadData() {
		if (this.id > -1) {
			Entity entity = LoadData(EntityName.Charge, this.id);
			setEntity(entity);
		}
	}

}
